//引入路由
import Vue from 'vue'
import VueRouter from 'vue-router'
//解决重复点击路由报错问题一
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

//引入路由组件
//引入Register部分的路由组件
import Register from '../pages/register/Register'
//引入Home部分的路由组件
import Home from '../pages/home/Home'
import Space from '../pages/home/Space'
import Discovery from '../pages/home/Discovery'
import ChatBox from '../pages/home/ChatBox'
import GroupDetails from '../pages/home/GroupDetails'
import UserDetails from '../pages/home/UserDetails'
import StandbyPage from '../pages/home/StandbyPage'
import AddChat from '../pages/home/AddChat'

//创建路由
export default new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/home/chatBox/standbyPage'
        },
        {
            path: '/register',
            name: 'Register',
            component: Register
        },
        {
            path: '/home',
            name: 'Home',
            component: Home,
            children: [
                {
                    path: 'space',
                    name: 'Space',
                    component: Space
                },
                {
                    path: 'discovery',
                    name: 'Discovery',
                    component: Discovery
                },
                {
                    path: 'chatBox',
                    name: 'ChatBox',
                    component: ChatBox,
                    children: [
                        {
                            path: 'groupDetails/:groupId',
                            name: 'GroupDetails',
                            component: GroupDetails
                        },
                        {
                            path: 'userDetails/:friendsId',
                            name: 'UserDetails',
                            component: UserDetails
                        },
                        {
                            path: 'standbyPage',
                            name: 'StandbyPage',
                            component: StandbyPage
                        },
                        {
                            path: 'addChat',
                            name: 'AddChat',
                            component: AddChat
                        }
                    ]
                }
            ]
        }
    ],
    mode: 'history'
})